//
//  ChangeView.m
//  hnGovernment
//
//  Created by 安仔 on 17/3/6.
//  Copyright © 2017年 安仔. All rights reserved.
//

#import "ChangeView.h"
#import "DDTextField.h"
#import "DDcacheManager.h"

@interface ChangeView()
@property (nonatomic,strong) DDTextField *textfield;
@end

@implementation ChangeView

- (instancetype) initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void) createView {
    
    
    self.signImg = [[UIImageView alloc] initWithFrame:CGRectMake(296 * m6Scale, 94 * m6Scale, 144 * m6Scale, 120 *m6Scale)];
    self.signImg.image = [UIImage imageNamed:@"绑定邮箱"];
    [self addSubview:self.signImg];
        
    self.signLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 164 * m6Scale, KScreenWidth, 60 * m6Scale)];
    NSString *title = [NSString stringWithFormat:@"当前昵称：%@",[cacheManager getUserModel].displayName];
    self.signLab.text = NSLocalString(title);
    self.signLab.textColor = [UIColor blackColor];
    self.signLab.font = [UIFont systemFontOfSize:38 * m6Scale];
    self.signLab.textAlignment = NSTextAlignmentCenter;
    self.signLab.hidden = YES;
    [self addSubview:self.signLab];
    
    self.phoneTF = [[GXJTextField alloc] initWithFrame:CGRectMake(72 * m6Scale, 294 * m6Scale, 600 * m6Scale, 80 * m6Scale)];
    self.phoneTF.placeholder = NSLocalString(@"请输入邮箱");
    self.phoneTF.cornerRadius = 6 * m6Scale;
    self.phoneTF.backgroundColor = RGB(252, 252, 252);
    self.phoneTF.layer.borderWidth = 2 * m6Scale;
    self.phoneTF.layer.borderColor = BackgroundColor.CGColor;
    self.phoneTF.delegate = self;
    [self addSubview:self.phoneTF];

    self.nextBtn = [[UIButton alloc] initWithFrame:CGRectMake(72 * m6Scale, 434 * m6Scale, 600 * m6Scale, 80 * m6Scale)];
    [self.nextBtn setTitle:NSLocalString(@"下一步") forState:0];
    [self.nextBtn setTitleColor:[UIColor whiteColor] forState:0];
    self.nextBtn.backgroundColor = RGB(210, 235, 255);
    self.nextBtn.layer.cornerRadius = 10 * m6Scale;
    [self.nextBtn addTarget:self action:@selector(nextController) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.nextBtn];

}

- (void)GXJtextFieldChangeText:(GXJTextField *)textField {
    
    if (self.isChangeName) {
        if (self.phoneTF.text.length > 0) {
            self.nextBtn.enabled = YES;
            self.nextBtn.backgroundColor = APPColor;
        }
    }else {
        if ([RegularRestrictions IsEmail:self.phoneTF.text]) {
            self.nextBtn.enabled = YES;
            self.nextBtn.backgroundColor = APPColor;
        } else {
            self.nextBtn.enabled = NO;
            self.nextBtn.backgroundColor = APPbuttonDisableColor;
        }
    }
}


- (void) nextController {
    if ([self.delegate respondsToSelector:@selector(clickNextBtn)]) {
        [self.delegate clickNextBtn];
    }
}

@end
